"use strict";
cc._RF.push(module, '01243gO7C9NarSoDrCjYxxm', 'cow');
// script/cow_project/cow.js

"use strict";

var cow_skin = cc.Class({
  name: 'cow_skin',
  properties: {
    cow_skins: {
      "default": [],
      type: [cc.SpriteFrame]
    }
  }
});
cc.Class({
  "extends": cc.Component,
  properties: {
    cow_type: {
      "default": [],
      type: [cow_skin]
    }
  },
  start: function start() {
    //奶牛类型切换
    this.number = Math.floor(Math.random() * this.cow_type.length);
    this.InterTime = 0;
  },
  update: function update(dt) {
    this.InterTime += dt; //

    var index = Math.floor(this.InterTime / 0.2);
    var cowType = this.cow_type[this.number];
    var cowScript = this.node.getComponent(cc.Sprite); // index %=3;
    //换肤到最后一个，重置index

    if (index >= cowType.cow_skins.length) {
      index = 0;
      this.InterTime = 0;
    }

    cowScript.spriteFrame = cowType.cow_skins[index];
  },
  runCallback: function runCallback() {
    this.number = Math.floor(Math.random() * this.cow_type.length);
    cc.log("一只牛跑过去了");
  }
});

cc._RF.pop();